<?php

namespace App\Http\Resources\Task;

use App\Http\Resources\Train\TrainOrder\TrainOrderResource;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use JsonSerializable;

class TrainSnapTaskInfoResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param Request $request
     *
     * @return array|Arrayable|JsonSerializable
     */
    public function toArray($request)
    {
        $task_info = parent::toArray($request);
        if (isset($task_info['order_info'])) {
            $task_info['order_info'] = new TrainOrderResource($task_info['order_info']);
            unset(
//				$task_info['order_info']['passengers'],
                $task_info['order_info']['other_fee']);
        }
        unset($task_info['user_id']);
        return $task_info;
    }
}
